<?php

namespace App\Http\Controllers\CallingCards\Wechat;


use App\Http\Controllers\BaseController;
use App\Service\CallingCards\LoginService;
use Illuminate\Http\Request;

class LoginController extends BaseController
{
    public function login(Request $request)
    {
        $this->validate($request, [
            'code'      => 'required|string',
        ]);
        try {
            $arr = LoginService::loginByWeChatCode($request->code);
        } catch (\Exception $exception) {
            return $this->fail(0, $exception->getMessage());
        }
        return $this->success(['jwtToken' => $arr['jwtToken'], 'expiredAt' => $arr['expiredAt']]);
    }


}
